@extends('app')

@section('content')
<ul class="nav nav-tabs">
    <li><a href="{{ url('/admin/content/banner')}}">列表</a></li>
    <li class="active"><a href="{{ url('/admin/content/banner/create') }}">添加</a></li>
</ul>
<form method="POST" action="{{ url('/admin/content/banner') }}">
<div class="panel panel-default mt20">

    <div class="table-responsive panel-body">
     <table class="table table-hover">
           <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">所属应用:</span>
                        <div class="col-sm-5 col-xs-8">
                            <select class="form-control" name="app">
                                <option value="index" @if($banners->app == 'index')selected @endif>首页</option>
                                <option value="bbs" @if($banners->app == 'bbs')selected @endif>社区</option>
                                <option value="employ" @if($banners->app == 'employ')selected @endif>就业指南</option>
                                <option value="teaches" @if($banners->app == 'teaches')selected @endif>充电加油</option>
                                <option value="company" @if($banners->app == 'company')selected @endif>招聘</option>
                            </select>
                            <div class="help-block" >选择个板块首页的banner轮播图，默认首页</div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">banner名称:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="title" id="title" value="{{ $banners->title }}">
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">banner描述:</span>
                        <div class="col-sm-5 col-xs-8">
                            <textarea class="form-control" rows="5" name="description" >{{$banners->description}}</textarea>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">连接地址:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="link" value="{{$banners->link}}">
                            <div class="help-block" >点击图片将会跳转至该地址</div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">banner图片:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input id="uploadimg" name="uploadimg" type="file" multiple="true" />
                            <div id="imgbox" class="dustbin">
                               @if($banners->aid > 0 && count($banners->attachment) > 0)
                                <div style="width:90px; height:60px;">
                                    <img width="90" height="60" src="{{$banners->attachment->url}}" />
                                    <input type='hidden' name='aid' value='{{$banners->aid}}' />
                                </div>
                               @endif
                            </div>
                             @if($app=='employ')
                            <div class="help-block" >图片尺寸请保证为 688 * 262。</div>
                            @elseif($app == 'bbs')
                            <div class="help-block" >图片尺寸请保证为 688 * 262。</div>
                            @elseif($app== 'teaches')
                            <div class="help-block" >图片尺寸请保证为 1920 * 340。</div>
                            @elseif($app== 'company')
                            <div class="help-block" >图片尺寸请保证为 688 * 262。</div>
                            @endif
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label">排序:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="sort" value="{{$banners->sort}}">
                            <div class="help-block" >越小越靠前</div>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div></div>
    <input type="hidden" name="blademode" value="{{ $blademode }}">
    <input type="hidden" name="bannerid" value="{{ $banners->id }}">
    {!! csrf_field() !!}
    <div class="form-inline mt20">
        <div class="form-group">
          <input type="submit" class="btn btn-primary btn-block" id="save" value="保存" />
        </div>
        <div class="form-group ml30">
            <input type="reset" class="btn btn-default btn-block" value="重置" />
        </div>
    </div>
</form>

<script type="text/javascript">
<!--
$(function(){
	/***图片上传****/
	$("#uploadimg").uploadify({
	    'formData'     : {
	        'fileField':'upfile',
	        '_token':'{{ csrf_token() }}',
	        'type':'banners'
	    },
	    "width"           : 120,
	    "height"          : 30,
	    "queueSizeLimit"  :1,
	    "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
	    "fileObjName"     : "upfile",
	    "buttonText"      : "上传图片",
	    "uploader"        : '/admin/upload/employimg',
	    'removeTimeout'	  : 1,
	    'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
	    'onUploadSuccess':function(file, data, response){
	    	var data = eval('(' + data + ')');
	        if (data.status == 'success') {

	        	var html="<div style='width:90px; height:60px;float:left;'>"
        			+"<img width='90' height='60' src='"+data.attach+"'  /><input type='hidden' name='aid' value='"+data.attach_id+"' />"
        			+"</div>"
       			$('#imgbox').html(html);
	        }else{
	            alert(data.msg);
	            return false;
	        }

	    }

	});
});
//-->
</script>
@endsection
